<!DOCTYPE html>












  


<html class="theme-next mist use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">









  
  
  <link rel="stylesheet" media="all" href="/lib/Han/dist/han.min.css?v=3.3">




<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



















  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.lug.ustc.edu.cn/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.4.2" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.jpg?v=6.4.2">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.jpg?v=6.4.2">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.jpg?v=6.4.2">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.2" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '6.4.2',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  




  <meta name="description" content="自从配置好了个人网站，就有不少朋友来问我怎么弄。那就写一篇小白教程吧。 如果你是第一次使用hexo，可以按照以下步骤，迅速看到结果   nodejs环境 安装hexo 本机测试  简介hexo是一个开源的静态博客系统。什么事静态博客呢？在现在互联网发达的今天，你理解成免费就可以了。 在开始之前，你首先要搞清楚为什么要使用hexo，如果只是想找个地方写东西，那么推荐你使用简书或者开一个个人的微信公众">
<meta name="keywords" content="hexo">
<meta property="og:type" content="article">
<meta property="og:title" content="从零开始创建一个个人网站">
<meta property="og:url" content="https://devzhao.com/post/34da75b0.html">
<meta property="og:site_name" content="学而时习之">
<meta property="og:description" content="自从配置好了个人网站，就有不少朋友来问我怎么弄。那就写一篇小白教程吧。 如果你是第一次使用hexo，可以按照以下步骤，迅速看到结果   nodejs环境 安装hexo 本机测试  简介hexo是一个开源的静态博客系统。什么事静态博客呢？在现在互联网发达的今天，你理解成免费就可以了。 在开始之前，你首先要搞清楚为什么要使用hexo，如果只是想找个地方写东西，那么推荐你使用简书或者开一个个人的微信公众">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://qnfile.sofiyu.com/blog/2018-11-25-115741.png">
<meta property="og:image" content="http://qnfile.sofiyu.com/blog/2018-11-25-110659.png">
<meta property="og:image" content="http://qnfile.devzhao.com/blog/2018-10-12-132801.png">
<meta property="og:image" content="http://qnfile.sofiyu.com/blog/2018-11-25-121457.png">
<meta property="og:image" content="https://qnfile.devzhao.com/blog/2018-10-12-095043.png">
<meta property="og:image" content="https://qnfile.devzhao.com/blog/2018-10-12-095044.png">
<meta property="og:image" content="http://qnfile.devzhao.com/18-10-11/34855621.jpg">
<meta property="og:image" content="http://qnfile.devzhao.com/18-10-11/54767988.jpg">
<meta property="og:image" content="https://qnfile.devzhao.com/blog/2018-10-12-095045.png">
<meta property="og:image" content="http://qnfile.devzhao.com/18-10-11/97440567.jpg">
<meta property="og:image" content="http://qnfile.devzhao.com/18-10-11/16449687.jpg">
<meta property="og:image" content="http://qnfile.devzhao.com/blog/2018-10-12-132147.png">
<meta property="og:image" content="http://qnfile.devzhao.com/blog/2018-10-12-124322.png">
<meta property="og:image" content="http://qnfile.devzhao.com/blog/2018-10-12-123800.png">
<meta property="og:image" content="http://qnfile.devzhao.com/blog/2018-10-12-130848.png">
<meta property="og:updated_time" content="2018-11-26T01:06:40.710Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="从零开始创建一个个人网站">
<meta name="twitter:description" content="自从配置好了个人网站，就有不少朋友来问我怎么弄。那就写一篇小白教程吧。 如果你是第一次使用hexo，可以按照以下步骤，迅速看到结果   nodejs环境 安装hexo 本机测试  简介hexo是一个开源的静态博客系统。什么事静态博客呢？在现在互联网发达的今天，你理解成免费就可以了。 在开始之前，你首先要搞清楚为什么要使用hexo，如果只是想找个地方写东西，那么推荐你使用简书或者开一个个人的微信公众">
<meta name="twitter:image" content="http://qnfile.sofiyu.com/blog/2018-11-25-115741.png">






  <link rel="canonical" href="https://devzhao.com/post/34da75b0.html"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>从零开始创建一个个人网站 | 学而时习之</title>
  






  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b8fcd96e6d9e134b3c9551097ed074a4";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div id="showImgFullScrn" style="display: none;"><img id="showImgFullScrnImg" src="" style="max-height:100%"></div>

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">学而时习之</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <h1 class="site-subtitle" itemprop="description">时间就是力量</h1>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-shortcut">
    <a href="/shortcut/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-shirtsinbulk"></i> <br />快捷</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br />关于</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />搜索</a>
        </li>
      
    </ul>
  

  
    

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://devzhao.com/post/34da75b0.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="zhaohan">
      <meta itemprop="description" content="教，是最好的学">
      <meta itemprop="image" content="http://qnfile.devzhao.com/blog/2018-10-12-125720.jpg#/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学而时习之">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">从零开始创建一个个人网站
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-10-12 13:24:51" itemprop="dateCreated datePublished" datetime="2018-10-12T13:24:51+08:00">2018-10-12</time>
            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/hexo/" itemprop="url" rel="index"><span itemprop="name">hexo</span></a></span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/post/34da75b0.html#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/post/34da75b0.html" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/post/34da75b0.html" class="leancloud_visitors" data-flag-title="从零开始创建一个个人网站">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数：</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          
            <div class="post-symbolscount">
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">本文字数：</span>
                
                <span title="本文字数">4.7k</span>
              

              

              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        <p>自从配置好了个人网站，就有不少朋友来问我怎么弄。那就写一篇小白教程吧。</p>
<p>如果你是第一次使用hexo，可以按照以下步骤，迅速看到结果</p>
<p><img src="http://qnfile.sofiyu.com/blog/2018-11-25-115741.png" alt=""></p>
<ul>
<li><a href="#hexo_node">nodejs环境</a></li>
<li><a href="#hexo_setup">安装hexo</a></li>
<li><a href="#hexo_test">本机测试</a></li>
</ul>
<h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>hexo是一个开源的静态博客系统。什么事静态博客呢？在现在互联网发达的今天，你理解成免费就可以了。</p>
<p>在开始之前，你首先要搞清楚为什么要使用hexo，如果只是想找个地方写东西，那么推荐你使用简书或者开一个个人的微信公众号，hexo不是你的最佳选择。</p>
<p>如果你是一个有强迫症的跨界选手，不想把所有类型的东西都放到公众号或者简书，那么hexo将是整合你所有输出内容的一个好地方。</p>
<p>再次整理hexo的东西，是因为朋友有一个“需要将部分文章加密”的需求。本来WordPress可以实现，但是发现 wordpress.com  的网站被墙了…总不能要求所有的人学会“科学上网”吧…..</p>
<h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2><p><img src="http://qnfile.sofiyu.com/blog/2018-11-25-110659.png" alt=""></p>
<h3 id="本机环境"><a href="#本机环境" class="headerlink" title="本机环境"></a>本机环境</h3><h4 id="git"><a href="#git" class="headerlink" title="git"></a>git</h4><p>进入<a href="https://gitforwindows.org/" target="_blank" rel="noopener">gitforwindows</a>,下载最新的安装包，安装，一路下一步即可。</p>
<h4 id="nodejs"><a href="#nodejs" class="headerlink" title="nodejs"></a><a name="hexo_node">nodejs</a></h4><p>进入<a href="https://nodejs.org/en/download/" target="_blank" rel="noopener">nodejs官网</a>，下载最新的安装包，安装，一路下一步即可。</p>
<h3 id="工具"><a href="#工具" class="headerlink" title="工具"></a>工具</h3><h4 id="Atom"><a href="#Atom" class="headerlink" title="Atom"></a><a href="https://atom.io/" target="_blank" rel="noopener">Atom</a></h4><p>最好用的编辑器，包括markdown文档和hexo的配置文件</p>
<p><a href="https://www.devzhao.com/post/42e658c3.html" target="_blank" rel="noopener">《Atom-一款好用的markdown编辑利器》</a></p>
<h4 id="sourceTree"><a href="#sourceTree" class="headerlink" title="sourceTree"></a><a href="https://www.sourcetreeapp.com/" target="_blank" rel="noopener">sourceTree</a></h4><p>你的站点建立好之后建议在代码托管里面单独建立一个私有项目，用于备份你的站点。如果需要使用其他的电脑写文章的时候，只需要配置好本机环境后再把备份的网站克隆下来就可以使用了。</p>
<p>Ps：第一次使用SourceTree的的时候，可能需要“科学上网”。</p>
<h4 id="图床工具"><a href="#图床工具" class="headerlink" title="图床工具"></a>图床工具</h4><p>win上：<a href="http://mpic.lzhaofu.cn/" target="_blank" rel="noopener">MPic</a></p>
<p>mac上：<a href="https://toolinbox.net/iPic/" target="_blank" rel="noopener">Ipic</a></p>
<p>网上看到一篇文章，总结的各种图床可以参考：<br><a href="https://blog.csdn.net/u012195214/article/details/79204607" target="_blank" rel="noopener">https://blog.csdn.net/u012195214/article/details/79204607</a></p>
<p>你可能还用得着一个工具(mac上)：<a href="https://itunes.apple.com/cn/app/id1183822957?ls=1&amp;mt=12" target="_blank" rel="noopener">ipicMover</a></p>
<p>可参考：<a href="https://www.waerfa.com/ipic-mover-review" target="_blank" rel="noopener">https://www.waerfa.com/ipic-mover-review</a></p>
<h3 id="图片存储空间"><a href="#图片存储空间" class="headerlink" title="图片存储空间"></a>图片存储空间</h3><p>用于存放图片等文件。</p>
<ul>
<li><p><a href="https://www.aliyun.com/product/oss?spm=5176.224200.search.2.44816ed6o5goAc" target="_blank" rel="noopener">阿里云oss</a></p>
<ul>
<li>优点：相对于七牛，oss的文件更新更快</li>
<li>缺点：没有免费的限额</li>
</ul>
</li>
</ul>
<ul>
<li><p><a href="https://www.qiniu.com/" target="_blank" rel="noopener">七牛</a></p>
<ul>
<li>优点：有10G的免费空间</li>
<li>缺点：文件更新慢</li>
</ul>
</li>
</ul>
<p>有两点注意：</p>
<ol>
<li>注册好后，需要进行实名认证，否则不能创建bucket。</li>
<li>给你的bucket绑定上域名。</li>
</ol>
<p>如果不清楚怎么绑定域名的，可以<a href="http://localhost:4000/about/#contact_me" target="_blank" rel="noopener">联系我</a>来更新这篇文章。</p>
<h4 id="页面托管"><a href="#页面托管" class="headerlink" title="页面托管"></a><a name="hexo_gitres">页面托管</a></h4><p>页面托管的平台后很多：coding、github、gitee…</p>
<p>以下只说coding的配置-&gt;<a href="https://coding.net/" target="_blank" rel="noopener">coding官网</a></p>
<ul>
<li><p>创建一个项目</p>
<ul>
<li><p>项目必须为公开的</p>
</li>
<li><p>如果你没有准备好域名，项目名称要与账户名字相同</p>
</li>
</ul>
</li>
<li><p>启用page</p>
</li>
</ul>
<p>用于存放个人网站的内容</p>
<h3 id="域名"><a href="#域名" class="headerlink" title="域名"></a>域名</h3><ul>
<li>注册</li>
</ul>
<p>想一个好的域名，<a href="https://wanwang.aliyun.com/" target="_blank" rel="noopener">去注册</a></p>
<ul>
<li>备案</li>
</ul>
<p>注册好域名后，在阿里云中进行备案。</p>
<p><img src="http://qnfile.devzhao.com/blog/2018-10-12-132801.png" alt=""></p>
<p>初次注册的时候，页面提示你需要购买一个阿里云的产品。</p>
<p>你可以找一个购买过阿里云产品的朋友（比如我😝😝😝，<a href="http://localhost:4000/about/#contact_me" target="_blank" rel="noopener">联系我</a>），跟他要一个备案号，就不用购买了。</p>
<p><font color="red" size="4" face="黑体">备案的过程很繁琐，但是很必要</font>，因为现在七牛云提供的域名会过期。</p>
<p>（我说这段时间怎么看很多文档的时候，图片都显示不出来）</p>
<h3 id="leancloud"><a href="#leancloud" class="headerlink" title="leancloud"></a><a href="https://leancloud.cn/" target="_blank" rel="noopener">leancloud</a></h3><p>用于存放评论和浏览统计</p>
<h3 id="百度统计"><a href="#百度统计" class="headerlink" title="百度统计"></a><a href="https://tongji.baidu.com" target="_blank" rel="noopener">百度统计</a></h3><p>用于统计站点的访问量</p>
<h3 id="markdown语法知识准备"><a href="#markdown语法知识准备" class="headerlink" title="markdown语法知识准备"></a>markdown语法知识准备</h3><p><a href="https://www.jianshu.com/p/b03a8d7b1719" target="_blank" rel="noopener">https://www.jianshu.com/p/b03a8d7b1719</a></p>
<h2 id="hexo安装使用"><a href="#hexo安装使用" class="headerlink" title="hexo安装使用"></a>hexo安装使用</h2><p><img src="http://qnfile.sofiyu.com/blog/2018-11-25-121457.png" alt=""></p>
<p>如果本地的node环境安装好了，就可以按照以下的步骤执行了</p>
<h3 id="安装hexo"><a href="#安装hexo" class="headerlink" title="安装hexo"></a><a name="hexo_setup">安装hexo</a></h3><p>hexo官网是<a href="https://hexo.io/zh-cn/" target="_blank" rel="noopener">https://hexo.io/zh-cn/</a></p>
<ol>
<li>下载安装</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ npm install hexo-cli -g</span><br><span class="line">$ cd 风水宝地</span><br><span class="line">$ hexo init devzhao.com</span><br><span class="line">$ cd devzhao.com</span><br><span class="line">$ npm install</span><br></pre></td></tr></table></figure>
<ul>
<li>安装的时候可能会卡主，可参考：<br><a href="https://www.jianshu.com/p/cce30447fc35" target="_blank" rel="noopener">https://www.jianshu.com/p/cce30447fc35</a></li>
</ul>
<p>上述执行完成后，你会看到如下目录结构：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">.</span><br><span class="line">├── _config.yml</span><br><span class="line">├── package.json</span><br><span class="line">├── scaffolds</span><br><span class="line">├── source</span><br><span class="line">|   ├── _drafts</span><br><span class="line">|   └── _posts</span><br><span class="line">└── themes</span><br></pre></td></tr></table></figure>
<p>其中</p>
<p><strong>_config.yml</strong></p>
<p>是网站的配置信息【也就是NEXT主题里面讲的“站点配置文件”】，您可以在此配置大部分的参数。</p>
<p><img src="https://qnfile.devzhao.com/blog/2018-10-12-095043.png" alt=""></p>
<p><strong>themes文件夹</strong></p>
<p>是主题路径，接下来配置的next主题就会出现在这</p>
<p>现在hexo的站点已经配置好了。我们来<a name="hexo_test">试一下</a>。</p>
<p>在devzhao.com的路径下，执行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ cd devzhao.com</span><br><span class="line">$ hexo s</span><br></pre></td></tr></table></figure>
<p>你会看到</p>
<p><img src="https://qnfile.devzhao.com/blog/2018-10-12-095044.png" alt=""></p>
<p>按住ctrl或command，鼠标点击上面的4000，就可以打开本地网站浏览了</p>
<h3 id="安装主题"><a href="#安装主题" class="headerlink" title="安装主题"></a>安装主题</h3><p>只说next主题</p>
<p>安装的时候要执行的命令是：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ cd devzhao.com</span><br><span class="line">$ git clone https://github.com/theme-next/hexo-theme-next themes/next</span><br></pre></td></tr></table></figure>
<p>命令执行完后，你会在上面提到的<strong>themes文件夹</strong>中看到,多了一个next</p>
<p><img src="http://qnfile.devzhao.com/18-10-11/34855621.jpg" alt=""></p>
<p>注意next文档中的不断强调的主题配置文件，就是这个next文件夹里面的</p>
<p><img src="http://qnfile.devzhao.com/18-10-11/54767988.jpg" alt=""></p>
<p>最新的next项目地址是：</p>
<p><a href="https://github.com/theme-next/hexo-theme-next" target="_blank" rel="noopener">https://github.com/theme-next/hexo-theme-next</a></p>
<hr>
<p>这里有个坑，你在百度上搜的时候很可能先看到的是这个网址</p>
<p><strong><a href="http://theme-next.iissnan.com/" target="_blank" rel="noopener">http://theme-next.iissnan.com/</a></strong></p>
<p>但实际上，next已经更新到这个站点了：</p>
<p><strong><a href="https://theme-next.org/" target="_blank" rel="noopener">https://theme-next.org/</a></strong></p>
<p><img src="https://qnfile.devzhao.com/blog/2018-10-12-095045.png" alt=""></p>
<p>在写这篇文章的时候，这个网站打不开了😶😶😶😶😶😶😶</p>
<p>我们只好看老版的文档。值得注意的是，老板文档的地址没有更新过来</p>
<p><img src="http://qnfile.devzhao.com/18-10-11/97440567.jpg" alt=""></p>
<hr>
<p>至此，next主题安装完成…</p>
<p>要使起生效，就要配置hexo使用next主题</p>
<ul>
<li>配置hexo使用next主题</li>
</ul>
<p>打开站点配置文件,将theme的配置改为next</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"># Extensions</span><br><span class="line">## Plugins: https://hexo.io/plugins/</span><br><span class="line">## Themes: https://hexo.io/themes/</span><br><span class="line">#theme: landscape</span><br><span class="line">theme: next</span><br></pre></td></tr></table></figure>
<h3 id="站点部署"><a href="#站点部署" class="headerlink" title="站点部署"></a>站点部署</h3><p>打开“站点配置文件”，在最后我们看到deploy配置项</p>
<p><img src="http://qnfile.devzhao.com/18-10-11/16449687.jpg" alt=""></p>
<p>进入coding，填上项目的地址，保存，我的配置如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line">  type: git</span><br><span class="line">  repo:  https://git.dev.tencent.com/zhaohan/zhaohan.coding.me.git</span><br><span class="line">  branch: master</span><br></pre></td></tr></table></figure>
<p>执行以下命令</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ cd devzhao.com</span><br><span class="line">$ hexo clean</span><br><span class="line">$ hexo g</span><br><span class="line">$ hexo d</span><br></pre></td></tr></table></figure>
<p>如果报错，那就下载一个插件，执行以下命令</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ cd devzhao.com</span><br><span class="line">$ npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure>
<p>再次执行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo d</span><br></pre></td></tr></table></figure>
<p>即可。</p>
<h3 id="网站备份"><a href="#网站备份" class="headerlink" title="网站备份"></a>网站备份</h3><h3 id="基本配置"><a href="#基本配置" class="headerlink" title="基本配置"></a>基本配置</h3><p>下面只说基本的配置，保证让你的网站正常运行。</p>
<p>更多其他配置，我会不定期更新到 <a href="https://www.devzhao.com/2018/10/11/hexo%E4%BC%98%E5%8C%96%E9%85%8D%E7%BD%AE/" target="_blank" rel="noopener">hexo优化配置</a>。</p>
<p>要注意区分后面的两个概念 “站点配置文件” 和 “主题配置文件”。</p>
<h4 id="配置hexo"><a href="#配置hexo" class="headerlink" title="配置hexo"></a>配置hexo</h4><h5 id="站点信息配置"><a href="#站点信息配置" class="headerlink" title="站点信息配置"></a>站点信息配置</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"># Site</span><br><span class="line">title: 学而时习之</span><br><span class="line">subtitle: 学而时习之，不亦说乎</span><br><span class="line">description: 记录日常，分享心得</span><br><span class="line">keywords:</span><br><span class="line">author: zhaohan</span><br><span class="line">language: zh-Hans</span><br><span class="line">timezone: Asia/Shanghai</span><br></pre></td></tr></table></figure>
<p>这里要注意,上面的language后面的值要和next主题里面的yml文件名匹配，hexo默认的主题是zh-Hans，但是next主题里的不一样</p>
<p><img src="http://qnfile.devzhao.com/blog/2018-10-12-132147.png" alt=""></p>
<h4 id="配置next主题"><a href="#配置next主题" class="headerlink" title="配置next主题"></a>配置next主题</h4><h5 id="next主题样式"><a href="#next主题样式" class="headerlink" title="next主题样式"></a>next主题样式</h5><p>next主题提供了4中样式，在Schemes中配置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"># Schemes</span><br><span class="line">#scheme: Muse</span><br><span class="line">#scheme: Mist</span><br><span class="line">scheme: Pisces</span><br><span class="line">#scheme: Gemini</span><br></pre></td></tr></table></figure>
<h5 id="文章访问量统计"><a href="#文章访问量统计" class="headerlink" title="文章访问量统计"></a>文章访问量统计</h5><p>1.登录learnCloud，创建class</p>
<p><img src="http://qnfile.devzhao.com/blog/2018-10-12-124322.png" alt=""></p>
<p><img src="http://qnfile.devzhao.com/blog/2018-10-12-123800.png" alt=""></p>
<p>2.修改主题配置文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"># Show number of visitors to each article.</span><br><span class="line"># You can visit https://leancloud.cn get AppID and AppKey.</span><br><span class="line">leancloud_visitors:</span><br><span class="line">  enable: true</span><br><span class="line">  app_id: &lt;learnCloud app_id&gt;</span><br><span class="line">  app_key: &lt;learnCloud app_key&gt;</span><br><span class="line">  # Dependencies: https://github.com/theme-next/hexo-leancloud-counter-security</span><br><span class="line">  # If you don&apos;t care about security in lc counter and just want to use it directly</span><br><span class="line">  # (without hexo-leancloud-counter-security plugin), set the `security` to `false`.</span><br><span class="line">  security: false</span><br><span class="line">  betterPerformance: false</span><br></pre></td></tr></table></figure>
<h5 id="Han-Support-支持汉字"><a href="#Han-Support-支持汉字" class="headerlink" title="Han Support 支持汉字"></a>Han Support 支持汉字</h5><p>1.进入theme/next目录下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ cd theme/next</span><br><span class="line">$ git clone https://github.com/theme-next/theme-next-han source/lib/Han</span><br></pre></td></tr></table></figure>
<p>2.设置汉字支持</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">han: true</span><br></pre></td></tr></table></figure>
<p>3.更新update</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ cd themes/next/source/lib/Han</span><br><span class="line">$ git pull</span><br></pre></td></tr></table></figure>
<p>注：通过该链接可以查看以上步骤 <a href="https://github.com/theme-next/theme-next-han" target="_blank" rel="noopener">https://github.com/theme-next/theme-next-han</a></p>
<h6 id="百度统计-1"><a href="#百度统计-1" class="headerlink" title="百度统计"></a>百度统计</h6><p>1.登录百度统计账号，获取百度统计id</p>
<p><img src="http://qnfile.devzhao.com/blog/2018-10-12-130848.png" alt=""></p>
<p>2.修改主题配置文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># Baidu Analytics ID</span><br><span class="line">baidu_analytics: b8fcd96e6d9e134b3c9551097ed074a4</span><br></pre></td></tr></table></figure>
<h4 id="配置hexo-blog-encrypted"><a href="#配置hexo-blog-encrypted" class="headerlink" title="配置hexo-blog-encrypted"></a>配置hexo-blog-encrypted</h4><p>插件的官方地址<br><a href="https://github.com/MikeCoder/hexo-blog-encrypt" target="_blank" rel="noopener">https://github.com/MikeCoder/hexo-blog-encrypt</a></p>
<p>1.安装</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ npm install --save hexo-blog-encrypt</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>修改站点配置文件，在最后添加</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"># Security</span><br><span class="line">##</span><br><span class="line">encrypt:</span><br><span class="line">    enable: true</span><br></pre></td></tr></table></figure>
<p>3.编辑markdown文件，在前面加上</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">password: 123</span><br><span class="line">abstract: 我是一篇加密文章，需要输入正确密码才能查看</span><br><span class="line">message: 为了保护隐私，你需要输入这篇文章的密码才能查看内容</span><br></pre></td></tr></table></figure>
<p>123是你要设的密码，后面的两个字段一试便知。</p>
<h4 id="配置Category"><a href="#配置Category" class="headerlink" title="配置Category"></a>配置Category</h4><h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h2><h3 id="第一次使用"><a href="#第一次使用" class="headerlink" title="第一次使用"></a>第一次使用</h3><h4 id="安装hexo-git插件"><a href="#安装hexo-git插件" class="headerlink" title="安装hexo git插件"></a>安装hexo git插件</h4><h4 id="写readme文件记录"><a href="#写readme文件记录" class="headerlink" title="写readme文件记录"></a>写readme文件记录</h4><h3 id="日后的日常使用"><a href="#日后的日常使用" class="headerlink" title="日后的日常使用"></a>日后的日常使用</h3><ul>
<li>本地调试</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo clean &amp;&amp; hexo g &amp;&amp; hexo s</span><br></pre></td></tr></table></figure>
<ul>
<li>部署</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo clean &amp;&amp; hexo g &amp;&amp; hexo d</span><br></pre></td></tr></table></figure>
<h4 id="养成备份的好习惯"><a href="#养成备份的好习惯" class="headerlink" title="养成备份的好习惯"></a>养成备份的好习惯</h4><h3 id="当你换了电脑"><a href="#当你换了电脑" class="headerlink" title="当你换了电脑"></a>当你换了电脑</h3>
      
    </div>

    

    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持分享输出，感谢你的支持！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.jpg" alt="zhaohan 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="zhaohan 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>zhaohan</li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://devzhao.com/post/34da75b0.html" title="从零开始创建一个个人网站">https://devzhao.com/post/34da75b0.html</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明出处！</li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/hexo/" rel="tag"># hexo</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/post/d9b33aa7.html" rel="next" title="hexo一篇文章前面到底有那些字段可以用">
                <i class="fa fa-chevron-left"></i> hexo一篇文章前面到底有那些字段可以用
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/post/d68fc82c.html" rel="prev" title="一些冷门，但是关键时刻能救命的小工具">
                一些冷门，但是关键时刻能救命的小工具 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="http://qnfile.devzhao.com/blog/2018-10-12-125720.jpg#/images/avatar.gif"
                alt="zhaohan" />
            
              <p class="site-author-name" itemprop="name">zhaohan</p>
              <p class="site-description motion-element" itemprop="description">教，是最好的学</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">148</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">33</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">29</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#简介"><span class="nav-number">1.</span> <span class="nav-text">简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#准备工作"><span class="nav-number">2.</span> <span class="nav-text">准备工作</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#本机环境"><span class="nav-number">2.1.</span> <span class="nav-text">本机环境</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#git"><span class="nav-number">2.1.1.</span> <span class="nav-text">git</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#nodejs"><span class="nav-number">2.1.2.</span> <span class="nav-text">nodejs</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#工具"><span class="nav-number">2.2.</span> <span class="nav-text">工具</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Atom"><span class="nav-number">2.2.1.</span> <span class="nav-text">Atom</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#sourceTree"><span class="nav-number">2.2.2.</span> <span class="nav-text">sourceTree</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#图床工具"><span class="nav-number">2.2.3.</span> <span class="nav-text">图床工具</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#图片存储空间"><span class="nav-number">2.3.</span> <span class="nav-text">图片存储空间</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#页面托管"><span class="nav-number">2.3.1.</span> <span class="nav-text">页面托管</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#域名"><span class="nav-number">2.4.</span> <span class="nav-text">域名</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#leancloud"><span class="nav-number">2.5.</span> <span class="nav-text">leancloud</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#百度统计"><span class="nav-number">2.6.</span> <span class="nav-text">百度统计</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#markdown语法知识准备"><span class="nav-number">2.7.</span> <span class="nav-text">markdown语法知识准备</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#hexo安装使用"><span class="nav-number">3.</span> <span class="nav-text">hexo安装使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#安装hexo"><span class="nav-number">3.1.</span> <span class="nav-text">安装hexo</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装主题"><span class="nav-number">3.2.</span> <span class="nav-text">安装主题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#站点部署"><span class="nav-number">3.3.</span> <span class="nav-text">站点部署</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#网站备份"><span class="nav-number">3.4.</span> <span class="nav-text">网站备份</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#基本配置"><span class="nav-number">3.5.</span> <span class="nav-text">基本配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#配置hexo"><span class="nav-number">3.5.1.</span> <span class="nav-text">配置hexo</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#站点信息配置"><span class="nav-number">3.5.1.1.</span> <span class="nav-text">站点信息配置</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#配置next主题"><span class="nav-number">3.5.2.</span> <span class="nav-text">配置next主题</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#next主题样式"><span class="nav-number">3.5.2.1.</span> <span class="nav-text">next主题样式</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#文章访问量统计"><span class="nav-number">3.5.2.2.</span> <span class="nav-text">文章访问量统计</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Han-Support-支持汉字"><span class="nav-number">3.5.2.3.</span> <span class="nav-text">Han Support 支持汉字</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#百度统计-1"><span class="nav-number">3.5.2.3.1.</span> <span class="nav-text">百度统计</span></a></li></ol></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#配置hexo-blog-encrypted"><span class="nav-number">3.5.3.</span> <span class="nav-text">配置hexo-blog-encrypted</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#配置Category"><span class="nav-number">3.5.4.</span> <span class="nav-text">配置Category</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用"><span class="nav-number">4.</span> <span class="nav-text">使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#第一次使用"><span class="nav-number">4.1.</span> <span class="nav-text">第一次使用</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#安装hexo-git插件"><span class="nav-number">4.1.1.</span> <span class="nav-text">安装hexo git插件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#写readme文件记录"><span class="nav-number">4.1.2.</span> <span class="nav-text">写readme文件记录</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#日后的日常使用"><span class="nav-number">4.2.</span> <span class="nav-text">日后的日常使用</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#养成备份的好习惯"><span class="nav-number">4.2.1.</span> <span class="nav-text">养成备份的好习惯</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#当你换了电脑"><span class="nav-number">4.3.</span> <span class="nav-text">当你换了电脑</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">zhaohan</span>

  

  
</div>


  










        
<div class="busuanzi-count">
  <!--<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>-->

  <script async src="//cdn.busuanzi.ibruce.info/cdn/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv" title="总访客量">
      <!-- <i class="fa fa-user-circle"></i> -->
      <i>已有</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      <i>位访客浏览过此网站</i>
    </span>
  

  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.2"></script>



  



  








  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  
  
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick';
    guest = guest.split(',').filter(function (item) {
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: true,
        notify: false,
        appId: 'z99UqRJEaGqxYLDPSPSx5jih-gzGzoHsz',
        appKey: 'N7MTJbRdufk8MAg3yeK6Gs9U',
        placeholder: '说点什么吧...',
        avatar:'mm',
        meta:guest,
        pageSize:'10' || 10,
        visitor: false
    });
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  
  <script>
    
    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();

      Counter('get', '/classes/Counter', { where: JSON.stringify({ url }) })
        .done(function ({ results }) {
          if (results.length > 0) {
            var counter = results[0];
            
            Counter('put', `/classes/Counter/${counter.objectId}`, JSON.stringify({ time: { "__op":"Increment", "amount":1 } }))
            
            .done(function () {
                  var $element = $(document.getElementById(url));
                  $element.find('.leancloud-visitors-count').text(counter.time + 1);
            })
            
            .fail(function ({ responseJSON }) {
                console.log('Failed to save Visitor num, with error message: ' + responseJSON.error);
            })
          } else {
            
              Counter('post', '/classes/Counter', JSON.stringify({ title: title, url: url, time: 1}))
                .done(function () {
                  var $element = $(document.getElementById(url));
                  $element.find('.leancloud-visitors-count').text(1);
                })
                .fail(function () {
                  console.log('Failed to create');
                });
            
          }
        })
      .fail(function ({ responseJSON }) {
        console.log('LeanCloud Counter Error:' + responseJSON.code + " " + responseJSON.error);
      });
    }
    

    $(function() {
      $.get('https://app-router.leancloud.cn/2/route?appId=' + "z99UqRJEaGqxYLDPSPSx5jih-gzGzoHsz")
        .done(function ({ api_server }) {
          var Counter = function (method, url, data) {
            return $.ajax({
              method: method,
              url: `https://${api_server}/1.1${url}`,
              headers: {
                'X-LC-Id': "z99UqRJEaGqxYLDPSPSx5jih-gzGzoHsz",
                'X-LC-Key': "N7MTJbRdufk8MAg3yeK6Gs9U",
                'Content-Type': 'application/json',
              },
              data: data,
            });
          };
          
          addCount(Counter);
          
        })
    });
  </script>



  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  
  

  

  

  

  

  

</body>
</html>
